﻿
namespace EasyStep
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using EasyStep.Data.Entities;
    using EasyStep.Business.Interfaces;

    public static class TestConstListHelper
    {

        public static TestConstList CreateDefault(this ITestConstantsListManager ConstsListManager, string name, Guid projectId)
        {
            return ConstsListManager.GetOrCreateConstList("default", projectId, () =>
                   new TestConstList() { Name = name, Description = "automatically generated constants list", ProjectId = projectId }
            );
        }


        public static TestConstList GetById(this ITestConstantsListManager ConstsListManager, Guid id, ITestConstantManager ConstManager = null, ITestProjectManager ProjectsManager = null)
        {
            var result = ConstsListManager.Get(id);
            if (ProjectsManager != null)
                result.Project = ProjectsManager.Get(result.ProjectId);
            if (ConstManager != null)
                result.Constants = ConstManager.GetAll().Where(c=>c.ListId==result.Id).OrderBy(c=>c.Name);
            return result;
        }
        
    }




    
}
